package com.culturalCenter.dataCenter.controller.web;

import com.culturalCenter.dataCenter.Utils.ApiResult;
import com.culturalCenter.dataCenter.Utils.ResultCode;
import com.culturalCenter.dataCenter.customEntity.responseParam.monitor.ElectricityResponse;
import com.culturalCenter.dataCenter.customEntity.responseParam.monitor.MeteotographResponse;
import com.culturalCenter.dataCenter.customEntity.responseParam.monitor.TemperatureResponse;
import com.culturalCenter.dataCenter.globalconfig.Interface.ApiVersion;
import com.culturalCenter.dataCenter.globalconfig.Interface.CustomVersion;
import com.culturalCenter.dataCenter.service.monitor.ElectricService;
import com.culturalCenter.dataCenter.service.monitor.MeteotographService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

import static com.culturalCenter.dataCenter.Utils.ApiResult.instance;

/**
 * 消防安全监测
 *
 * @author 方治森
 * @since 2022/2/10
 */
@RestController
@RequestMapping("/{version}/monitor")
@Api(tags = "消防安全监测")
@ApiVersion(CustomVersion.VERSION_1)
@Slf4j
public class MonitorController {

    @Resource
    private ElectricService electricService;
    @Resource
    private MeteotographService meteotographService;

    /**
     * 智慧用电
     */
    @GetMapping("/electricList")
    @ApiOperation(value = "智慧用电")
    public ApiResult<ElectricityResponse> electricList() {
        ElectricityResponse electricityResponse = electricService.getStatus();
        return instance(ResultCode.SUCCESS, electricityResponse);
    }

    /**
     * 气象
     */
    @GetMapping("/weather")
    @ApiOperation(value = "气象")
    public ApiResult<MeteotographResponse> weather() {
        MeteotographResponse meteotographResponse = meteotographService.getAll();
        return instance(ResultCode.SUCCESS, meteotographResponse);
    }


    /**
     * 气温
     */
    @GetMapping("/temperature")
    @ApiOperation(value = "气温")
    public ApiResult<TemperatureResponse> temperature() {
        TemperatureResponse temperature = meteotographService.getTemperature();
        return instance(ResultCode.SUCCESS, temperature);
    }

}
